package com.yyq.common;

/**
 * @author yyq
 * @create 2021-08-03 21:08
 */
public class Good implements Comparable{
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }



    private String name;
    private double price;

    public Good(String name,double price){
        this.price=price;
        this.name=name;
    }

    @Override
    public int compareTo(Object o) {
        if( o instanceof Good){
            Good good=(Good)o;
            if(this.price>good.price) return 1;
            else if(this.price<good.price) return -1;
            else return 0;
        }
        throw new RuntimeException("传入的数据类型有问题");
    }
}
